Page({
    data: {
       productList:[
            {imageUrl:'../../image/lvyou@2x.png',title:'中联6012原厂标准节80节标',time:'2019-07-11',
            address:'湖北武汉',headerImage:'../../image/installheaderimg.jpg',boss:'李老板',cnt:8,money:16.32},
            {imageUrl:'../../image/lvyou@2x.png',title:'中联6012原厂标准节80节标',time:'2019-07-11',
            address:'湖北武汉',headerImage:'../../image/installheaderimg.jpg',boss:'李老板',cnt:8,money:16.32},
            {imageUrl:'../../image/lvyou@2x.png',title:'中联6012原厂标准节80节标',time:'2019-07-11',
            address:'湖北武汉',headerImage:'../../image/installheaderimg.jpg',boss:'李老板',cnt:8,money:16.32},
            {imageUrl:'../../image/lvyou@2x.png',title:'中联6012原厂标准节80节标',time:'2019-07-11',
            address:'湖北武汉',headerImage:'../../image/installheaderimg.jpg',boss:'李老板',cnt:8,money:16.32},
            {imageUrl:'../../image/lvyou@2x.png',title:'中联6012原厂标准节80节标',time:'2019-07-11',
            address:'湖北武汉',headerImage:'../../image/installheaderimg.jpg',boss:'李老板',cnt:8,money:16.32},
            {imageUrl:'../../image/lvyou@2x.png',title:'中联6012原厂标准节80节标',time:'2019-07-11',
            address:'湖北武汉',headerImage:'../../image/installheaderimg.jpg',boss:'李老板',cnt:8,money:16.32}
        ],
        showList:[],
        arr1:[],
        arr2:[],
        arr3:[],
        select:20,
        pageNum:1,
        current:1,
        pagesize:20,
        pages:1

    },
    onLoad: function(options) {
       var userInfo= wx.getStorageSync('userInfo');
        this.setData({
            userInfo:userInfo
        })
         this.getMySheBei();
    },
    onReady: function() {
        // 生命周期函数--监听页面初次渲染完成

    },
     //上拉加载更多
    onReachBottom:function(){
        console.log('加载更多')
        this.setData({
          current:this.data.current+1
        })
         if (this.data.current<=this.data.pages) {
          this.getMySheBei();
         }  
    },
    getMySheBei:function () {
         var _self=this;
         wx.request({
            url:getApp().globalData.baseUrl+'/wx/equipment/publish/getList?status='+this.data.select+'&openid='+this.data.userInfo.openid+'&current='+this.data.current+'&pagesize='+this.data.pagesize,
            method:"GET",
            header: {
                'openid':this.data.userInfo.openid, //公用请求头
                'content-type': 'application/json'
            },
            success: function(res) {
           
            //  var  arr1=[];
            //  var  arr2=[];
            //  var  arr3=[];
            // for(var i=0;i<res.data.obj.list.length;i++){
            //       if (res.data.obj.list[i].status==20) {
            //         arr1.push(res.data.obj.list[i])
            //       }else if(res.data.obj.list[i].status==10){
            //         arr2.push(res.data.obj.list[i])
            //       }else if(res.data.obj.list[i].status==30){
            //         arr3.push(res.data.obj.list[i])
            //       }
            // }
             _self.setData({
                showList:_self.data.showList.concat(res.data.obj.list),
                pages:res.data.obj.pages
             })
             
         }
     })
            
    },
    onShow: function() {
        // 生命周期函数--监听页面显示
        // 生命周期函数--监听页面加 String2
       


    },
    onHide: function() {
        // 生命周期函数--监听页面隐藏

    },
    toTop:function(code){
      console.log(code.detail)
         console.log(code.detail)
       // body...
      var id=code.detail;
     console.log(code.detail)
     var _self=this;
        wx.showModal({
          title: '提示',
          content: '是否确定置顶?',
          success (res) {
            if (res.confirm) {
              console.log('用户点击确定')
               wx.request({
                    url:getApp().globalData.baseUrl+'/wx/equipment/top/save',
                    method:"POST",
                     header: {
                        'openid':_self.data.userInfo.openid, //公用请求头
                        'content-type': 'application/json'
                    },
                    data:{
                       "equId":id,
                       'openid':_self.data.userInfo.openid
                    },
                    success: function(res) {
                    wx.showToast({
                    title: res.data.des,
                    icon:'none',
                    duration: 2000
                  })
                     
                 }
               })
            } else if (res.cancel) {
              console.log('用户点击取消')

            }
          }
        })
    },
    sale:function (code) {
      console.log(code.detail)
       // body...
      var id=code.detail;
     console.log(code.detail)
     var _self=this;
        wx.showModal({
          title: '提示',
          content: '是否确定已卖出?',
          success (res) {
            if (res.confirm) {
              console.log('用户点击确定')
               wx.request({
                    url:getApp().globalData.baseUrl+'/wx/equipment/update',
                    method:"POST",
                     header: {
                        'openid':_self.data.userInfo.openid, //公用请求头
                        'content-type': 'application/json'
                    },
                    data:{
                       "id":id,
                       "status":30,
                       'openid':_self.data.userInfo.openid
                    },
                    success: function(res) {
                    _self.getMySheBei();
                     
                 }
               })
            } else if (res.cancel) {
              console.log('用户点击取消')

            }
          }
        })
    },
    delete:function (code) {
      // body...
      var id=code.detail;
     console.log(code.detail)
     var _self=this;
        wx.showModal({
          title: '提示',
          content: '是否确定删除?',
          success (res) {
            if (res.confirm) {
              console.log('用户点击确定')
               wx.request({
                    url:getApp().globalData.baseUrl+'/wx/equipment/update',
                    method:"POST",
                     header: {
                        'openid':_self.data.userInfo.openid, //公用请求头
                        'content-type': 'application/json'
                    },
                    data:{
                       "id":id,
                       "yn":0,
                       'openid':_self.data.userInfo.openid
                    },
                    success: function(res) {
                    _self.getMySheBei();
                     
                 }
               })
            } else if (res.cancel) {
              console.log('用户点击取消')

            }
          }
        })
     
    },
    edit:function (code) {
      // body...
      console.log(code.detail)
       wx.navigateTo({
        url: '/pages/changeSheBei/changeSheBei?id='+code.detail
      })
      
    },
    allSend:function (e) {
      console.log(e.currentTarget.dataset.code)
      var code=e.currentTarget.dataset.code;
      this.setData({
        select:code,
        current:1,
        showList:[]
      })
      this.getMySheBei();
      // if (code==20) {
      //   this.setData({    
      //     showList:this.data.arr1
      //    })
      // }else if(code==10){
      //    this.setData({    
      //     showList:this.data.arr2
      //    })
      // }else if(code==30){
      //    this.setData({    
      //     showList:this.data.arr3
      //    })
      // }
       
    }
      

})